{% extends 'cms/cms_base.html' %}
{% from 'common/_macro.html' import static %}
{% block title %}
    帖子管理
{% endblock %}
{% block page_title%}
{{ self.title() }}
{% endblock %}
{% block head %}
    <script src="{{ static('cms/js/posts.js') }}"></script>
{% endblock %}
{% block page_content %}
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>帖子名称</th>
                <th>发布时间</th>
                <th>作者</th>
                <th>所属模块</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {% for post in posts %}
            <tr data-id="{{ post.id }}" data-highlight="{{ 1 if post.highlight else 0 }}" data-firelag="{{ 1 if post.firelag else 0 }}">
                <td><a target="_blank" href="{{ url_for('front.pdetail',post_id=post.id) }}">{{ post.title }}</a></td>
                <td>{{ post.create_time }}</td>
                <td>{{ post.author.username }}</td>
                <td>{{ post.board.name }}</td>
                <td>
                    {% if post.highlight %}
                        <button class="btn btn-success btn-xs highlight-btn">取消加精</button>
                    {% else %}
                        <button class="btn btn-success btn-xs highlight-btn">加精</button>
                    {% endif %}
                    {% if post.firelag %}
                        <button class="btn btn-warning btn-xs fire-btn">取消热帖</button>
                        {% else %}
                        <button class="btn btn-warning btn-xs fire-btn">加热</button>
                    {% endif %}
                    <button class="btn btn-danger btn-xs del-post">删除</button>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <div class="page-nate" style="text-align: center">
        {{ pagination.links }}
    </div>
{% endblock %}